home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCEPT_H
- #define FWEXCEPT_H
- //========================================================================================
- //
- // File: FWExcept.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWCLAINF_H
- #include "FWClaInf.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- //========================================================================================
- // Exception classes definition and implementation macros
- //========================================================================================
-
- #define _FW_EXCEPTION_DEFINE(name) \
- public: \
- FW_DECLARE_CLASS
-
- #define _FW_EXCEPTION_IMPLEMENT_ROOT(name) \
- FW_DEFINE_CLASS_M0(name)
-
- #define _FW_EXCEPTION_IMPLEMENT(name, ancestor) \
- FW_DEFINE_CLASS_M1(name, ancestor)
-
- //========================================================================================
- // CLASS _FW_CException
- //========================================================================================
-
- class _FW_CException
- {
- public:
- virtual ~_FW_CException();
- _FW_CException();
-
- int __IsKindOf(FW_ClassReference aClass);
- // Returns 1 if this object is a kind of aClass, i.e. same or subclass of aClass.
-
- size_t GetSize() const;
- // Returns the size of this object, using info from its metaclass
- // This method is not virtual, but will work correctly since PrivVirtualGetClassInfo is virtual.
-
- virtual void Copy(void *p, size_t maxObjectSize) const;
- // Copies this object. This method does a bitwise copy, but subclasses
- // must override to perform a deep copy.
-
- void Delete();
- // Calls the virtual destructor, but does not attept to delete storage.
-
- const char* GetClassName() const;
- // Returns the class name of this object, as a string.
- // This method is not virtual, but will work correctly since PrivVirtualGetClassInfo is virtual.
-
- #ifdef FW_DEBUG
- short fIsValid;
- #endif
-
- _FW_EXCEPTION_DEFINE(_FW_CException)
-
- public:
- // these are provided to mask a bug in Borland C++ (it calls delete when
- // you just want to call the dtor, explicitly)
- void* operator new(size_t size);
- void operator delete(void* memory);
- };
-
- //========================================================================================
- // CLASS _FW_CException inline functions
- //========================================================================================
-
- inline size_t _FW_CException::GetSize() const
- {
- FW_PRIV_ASSERT(fIsValid==1);
- return PrivVirtualGetClassInfo()->GetInstanceSize();
- }
-
- inline const char* _FW_CException::GetClassName() const
- {
- FW_PRIV_ASSERT(fIsValid==1);
- return PrivVirtualGetClassInfo()->GetClassName();
- }
-
- inline void _FW_CException::Delete()
- {
- FW_PRIV_ASSERT(fIsValid==1);
- #ifdef _MPWCFRONT
- // MPW CFront is not supported with this version of the code
- FW_PRIV_ASSERT(FALSE);
- // CFront is bizarre. It won't allow the unscoped destructor name, but the scoped
- // name is dispatched virtually, even though ARM says scoped names are never virtual.
- this->_FW_CException::~_FW_CException();
- #else
- this->~_FW_CException(); // Virtual dispatch to object's destructor
- #endif
- FW_PRIV_ASSERT(fIsValid==0);
- }
-
- #endif
-